package mx.com.crowdgine.assetloader;

public class Face {
	private Vertex v[] = new Vertex[3];
	private Normal n[] = new Normal[3];
	private TexCoordinate tc[] = new TexCoordinate[3];
	
	public Face(Vertex v1, Vertex v2, Vertex v3){
		v[0]=v1;
		v[1]=v2;
		v[2]=v3;
	}
	
	public Face(Vertex array[]){
		if(array.length!=3){
			System.out.println("Could not create face, array length different than 3");
		}
		else{
			v[0]=array[0];
			v[1]=array[1];
			v[2]=array[2];
		}
	}
	
	public Face(Vertex vArr[], Normal nArr[]){
		if(vArr.length!=3 || nArr.length!=3){
			System.out.println("Could not create face, array length different than 3");
		}
		else{
			for(int i=0;i<v.length;i++){
				v[i]=vArr[i];
				n[i]=nArr[i];
			}
		}
	}
	
	public Face(Vertex vArr[], TexCoordinate tcArr[]){
		if(vArr.length!=3 || tcArr.length!=3){
			System.out.println("Could not create face, array length different than 3");
		}
		else{
			for(int i=0;i<v.length;i++){
				v[i]=vArr[i];
				tc[i]=tcArr[i];
			}
		}
	}
	
	public Face(Vertex vArr[], Normal nArr[], TexCoordinate tcArr[]){
		if(vArr.length!=3 || nArr.length!=3 || tcArr.length!=3){
			System.out.println("Could not create face, array length different than 3");
		}
		else{
			for(int i=0;i<v.length;i++){
				v[i]=vArr[i];
				n[i]=nArr[i];
				tc[i]=tcArr[i];
			}
		}
	}
	
	public String toString(){
		String s=new String();
		s+="Face Info:   Vertices:";
		for (int i=0;i<v.length;i++){
			s+=v[i].toString();
		}
		s+="\n\nFace Info:   Normals:";
		for (int i=0;i<v.length;i++){
			s+=n[i].toString();
		}
		s+="\n\nFace Info:   TexCoords:";
		for (int i=0;i<v.length;i++){
			s+=tc[i].toString();
		}
		return	s;
	}
	
	public int getNumVertices() {
		if(v == null)
			return 0;
		else
			return v.length;
	}
	
	public Vertex getVertex(int i) {
		return v[i];
	}
	
	public Normal getNormal(int i) {
		return n[i];
	}
	
	public TexCoordinate getTexCoordinate(int i) {
		return tc[i];
	}
}
